#pragma once

#include "sceneobject.h"
#include "physics_object.h"
#include <list>



class AxisHandle : public SceneObject
{
public:
	Vec3f m_position;
	Vec3f axis;
	float speed; 
	// TODO scaleMode = bad design?
	bool scaleMode;
	AxisHandle() : SceneObject(), speed(0.0f) { };
	virtual ~AxisHandle() {};
	virtual void vRender();
	virtual void vPicking();
	virtual Vec3f vGetPosition() { return m_position; }
	virtual void vSetPosition(const Vec3f &newPos) { m_position = newPos; }

	bool vIsManipulator() const
	{ 
		return true; 
	}
	virtual void vInteractWith( SceneObject *mutator );

	void getGLTransform(float mtx[16] ) const {  } 
	virtual TorPhysix::PhysicsObject* vGetPhysicsObject() const { return 0x0; }
};

class AngleHandle : public SceneObject
{
private:
public:
	Vec3f m_position;
	Vec3f axis;
	float speed;
	AngleHandle() : SceneObject(),  speed(0.0f) { };
	virtual ~AngleHandle() {};
	virtual void vRender();
	virtual void vPicking();
	virtual Vec3f vGetPosition() { return m_position; }
	virtual void vSetPosition(const Vec3f &newPos) { m_position = newPos; }

	bool vIsManipulator() const
	{ 
		return true; 
	}
	virtual void vInteractWith( SceneObject *mutator );

	void getGLTransform(float mtx[16] ) const {  } 
	virtual TorPhysix::PhysicsObject* vGetPhysicsObject() const { return 0x0; }
};

class Manipulator
{
protected:
private:
	AxisHandle x_handle;
	AxisHandle y_handle;
	AxisHandle z_handle;

	AngleHandle x_angular_handle;
	AngleHandle y_angular_handle;
	AngleHandle z_angular_handle;
public:
	SceneObject *selectedSceneObj;
	SceneObject *selectedTool;
	bool isSelected;

	Manipulator() : isSelected(false), selectedSceneObj(NULL), selectedTool(NULL)  { init(); };
	~Manipulator() {};
	void init();
	void render();
	void addHandlesToList( std::list< SceneObject* > &sceneObjects );
	void setSceneObject( SceneObject * sceneObject );
	void update(float speed);
	void setScaling( bool scaleActive );
	void activateTool( SceneObject *tool );
	void useActiveTool();
};